import 'package:flutter/cupertino.dart';
import 'package:imember/Util/Global.dart';
import 'package:imember/Util/MyColor.dart';
import 'package:imember/Widget/MyButton.dart';
import 'package:imember/Widget/MyInput.dart';
import 'package:imember/Widget/MyPage.dart';

class StockTake extends StatefulWidget {
  static int Purchases = 1; //進貨
  static int Stock = 2; //庫存
  int type;

  StockTake(this.type);

  @override
  State<StatefulWidget> createState() {
    return StockTakeState();
  }
}

class StockTakeState extends State<StockTake> {
  @override
  Widget build(BuildContext context) {
    return MyPage(
        Container(
          padding: EdgeInsets.fromLTRB(50, 24, 50, 50),
          child: Column(
            children: [
              Expanded(
                  child: GridView.builder(
                      gridDelegate:
                          SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, mainAxisSpacing: 10, childAspectRatio: 10),
                      itemCount: 24,
                      itemBuilder: (BuildContext context, int index) {
                        return ItemInput();
                      })),
              Container(height: 24),
              Row(mainAxisAlignment: MainAxisAlignment.end, children: [
                IconBtn("儲存並列印", "ic_printer.png", width: 170),
                Container(width: 13),
                IconBtn("儲存", "ic_check.png", width: 120, bgColor: MyColor.Orange),
                Container(width: 34),
              ])
            ],
          ),
        ),
        title: widget.type == StockTake.Purchases ? "進貨盤點" : "庫存盤點");
  }
}

class ItemInput extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
        padding: EdgeInsets.fromLTRB(34, 0, 34, 0),
        child: Row(
          children: [
            Text("義大利麵", style: TextStyle(fontSize: 20, color: MyColor.C66, fontWeight: FontWeight.bold)),
            Expanded(
                child: Container(
              height: 39,
              margin: EdgeInsets.only(left: 24),
              decoration: Global.getBoxBg(23, MyColor.F2),
              padding: EdgeInsets.fromLTRB(27, 0, 27, 0),
              child: NormalInput(hintText: "輸入數量", fontSize: 20, inputType: NormalInput.Number),
            ))
          ],
        ));
  }
}
